package com.example.admin.testdemo.util;

public class WeightCmd {
    private static String temp1 = "010300010001D5CA";
    private static String temp2 = "020300010001D5F9";
    private static String temp3 = "030300010001D428";
    private static String temp4 = "040300010001D59F";
    private static String temp5 = "050300010001D44E";

    public static byte[] getCdmData(int add) {
        String temp = temp1;
        if (add == 1) {
            temp = temp1;
        } else if (add == 2) {
            temp = temp2;
        } else if (add == 3) {
            temp = temp3;
        } else if (add == 4) {
            temp = temp4;
        } else if (add == 5) {
            temp = temp5;
        } else {
            temp = temp1;
        }

        return ByteUtil.hexStr2bytes(temp);
    }

    public static boolean cmdFH(byte [] data){

        if((data[0]==(byte)0x01||data[0]==(byte)0x02||data[0]==(byte)0x03||data[0]==(byte)0x04||
                data[0]==(byte)0x05)&&data[1]==(byte)0x03&&data[2]==(byte)0x04){
            return true;
        }
        return false;
    }

    public static int weight(byte[] data){
        int number1 = 0;
        int number2 = 0;
        number1 |= ((data[3] << 8) & 0xFF00);
        number2 |= (data[4] & 0x00FF);
        return number1+number2;
    }
}
